import base64

# 固定密钥
KEY = "1234567890123456"

def encrypt_password(password: str) -> str:
    """
    使用固定密钥加密密码
    :param password: 原始密码
    :return: 加密后的密码
    """
    encrypted = ''.join(chr(ord(p) ^ ord(k)) for p, k in zip(password, KEY))
    return base64.b64encode(encrypted.encode()).decode()

def decrypt_password(encrypted_password: str) -> str:
    """
    使用固定密钥解密密码
    :param encrypted_password: 加密后的密码
    :return: 原始密码
    """
    encrypted = base64.b64decode(encrypted_password).decode()
    decrypted = ''.join(chr(ord(p) ^ ord(k)) for p, k in zip(encrypted, KEY))
    return decrypted

if __name__ == "__main__":
    # 测试加密功能
    encrypted_password = "123456"
    encrypted = encrypt_password(encrypted_password)
    print(encrypted)

    # 测试解密功能
    encrypted_password = "AAAAAAAA"
    decrypted = decrypt_password(encrypted_password)
    print(decrypted)
